<?php !defined('DEBUG') AND exit('Forbidden'); include _include(ADMIN_PATH.'view/htm/header.inc.htm');
$num_pid = db_count('user_pay',array('status'=>'0','type'=>'2'));$page = param(1,1);
$data =  db_find('user_pay',array('type'=>2,'status'=>0), array('time'=>-1), $page, $pagesize = 20);
$pagination = pagination(url("tt_deposit-{page}"), $num_pid, $page, $pagesize);
function username($uid)
{$r = db_find_one('user',array("uid"=>$uid)); return $r['username'];}
$pay_num=db_count('user_pay',array('status'=>'0','type'=>'3'));
$set=setting_get('tt_deposit');
?>
<style>.opt{color:dodgerblue;cursor:pointer;margin:3px 9px;display:inline-block; height:30px; width:auto; }  .opt:hover{color:red;}</style>
<div class="row"><div class="col-lg-10 mx-auto"><div class="card"><div class="card-body" ><h3>后期技术支持</h3>官方网站：http://www.6rabbit.com/ <a href="http://www.6rabbit.com"target="_blank" style="text-decoration: none">点击进入</a><br>官方QQ群：58911696（正常群）、77868272（只吹牛不讨论正事）</div></div>
    <div class="card"><div class="card-body" ><h3>最低提现/充值金额</h3>单位:分，请不要输入小数点、特殊字符等。建议设置1000（10元）防止恶意提交刷数据库。<input id="input_min" type="text" maxlength="8" value="<?php echo $set['min']; ?>" class="form-control"/><hr><h3>邮箱发送设置</h3>
        <input type="checkbox" name="open_email" value="1" id="open_email" <?php echo ($set['mail_notify']==1)?'checked':'';?>/><label for="open_email">当有人提交审核时，向管理员发送邮件（需要预先配置好SMTP）</label><br>
        管理员邮箱：<input class="form-control" name="admin_email" id="admin_email" value="<?php echo $set['mail_to'];?>"/>
        <button type="submit" class="btn btn-primary" id="submit_min" data-loading-text="<?php echo lang('submiting');?>..."><?php echo lang('confirm');?></button></div></div>
    <div class="card"><div class="card-body" ><a href="<?php echo url('deposit_payperson');?>"><h3>审核充值请求 (<?php echo $pay_num;?>)</a></h3></div></div>
<div class="card"><div class="card-body" ><h3>审核提现请求 (<?php echo $num_pid;?>)</h3><table class="table">
    <tr><th>cid</th><th>用户</th><th>附加信息</th><th>金额</th><th>时间</th><th>操作</th></tr>
    <?php foreach($data as $v){?><tr id="li<?php echo $v['cid'];?>">
    <td><?php echo $v['cid'];?></td><td><?php echo username($v['uid']);?></td><td><?php echo $v['code']; ?></td><td>¥<?php echo ($v['num']/100.0);?></td><td><?php echo date('Y-m-d H:i:s',$v['time']); ?></td><td><span class="opt" onclick="set(1,<?php echo $v['cid'];?>);">通过</span><span class="opt" onclick="set(-1,<?php echo $v['cid'];?>);">驳回不退还积分</span><span class="opt" onclick="set(-2,<?php echo $v['cid'];?>);">驳回退还积分</span></td>
    </tr><?php }?></table>
    <nav class="text-center"><ul class="pagination"><?php echo $pagination; ?></ul></nav>
</div></div></div></div>
<?php include _include(ADMIN_PATH.'view/htm/footer.inc.htm');?>
<script>
    var jbtn= $("#submit_min"); var jmin=$("#input_min"); var jmailto=$("#admin_email"); var jopen_mail=$("#open_email");
    jbtn.on("click",function(){
        var postdata = new Array();
        postdata['min'] = jmin.val(); postdata['op']=1; postdata['admin_email']=jmailto.val(); postdata['open_email']=jopen_mail.val();
        $.xpost("<?php echo url('plugin-setting-tt_deposit');?>", serialize_array(postdata), function(code, message) {
            if(code == 0) {$.alert(message);} else {$.alert(message);}
        });
    });
function set(opt,cid) {
    var jli=$("#li"+cid) ;jli.fadeOut();var postdata = new Array();
    postdata['opt']=opt; postdata['cid'] = cid; postdata['op']=0;
    $.xpost("<?php echo url('plugin-setting-tt_deposit');?>", serialize_array(postdata), function(code, message) {
        if(code == 0) return; else {$.alert(message);jli.fadeIn();}
    });
}
function serialize_array(arr) {
    var first = 1; var rtn="";
    for(var key in arr){
        if(first!=1) rtn+="&"; else first=0;
        rtn+= key+"="+arr[key];
    } return rtn;
}
</script>